package S16.second;

import java.io.File;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Comparator;

public class S02 {

	public static void main(String[] args) {
		File dir = new File("D:\\");
		File[] files = dir.listFiles();
		Arrays.stream(files)
			.sorted(Comparator.comparingLong(f->f.lastModified()))
			.sorted(Comparator.comparingInt(f->f.isDirectory()?0:1))
		
			.forEach(f->{
				Instant instant = Instant.ofEpochMilli(f.lastModified());
				LocalDateTime dateTime = LocalDateTime.ofInstant(instant, ZoneId.of("PRC"));
				System.out.printf("%tF %<tT",dateTime);
				if(f.isDirectory())System.out.print("  <DIR>                ");
				else System.out.printf("%,21d  ", f.length());
				System.out.println(f.getName());
			});
		
	}

}
